package com_djm_2025_05_15;

/**
 * @author dengjiangming
 * @version 1.1.0
 * @date 2025-05-15
 */
public class Demo7 {

    //递归求解汉诺塔问题
    public static void move(char p1,char p2){
        System.out.printf("%c -> %c \n",p1,p2);
    }


    public static void Hannoi(int n,char p1,char p2,char p3){
        if(n == 1){
            move(p1,p3);
            return;
        }

        Hannoi(n-1,p1,p3,p2);
        move(p1,p3);
        Hannoi(n-1,p2,p1,p3);
    }
    public static void main(String[] args) {
          Hannoi(3,'A','B','C');
    }
}
